fix: Correct sort length access in applyQueryOptions #40190
fix: Correct sort length access in applyQueryOptions #40190Naetiksoni08 wants to merge 4 commits intoRocketChat:developfrom
Conversation
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughUpdated iteration bounds in Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Suggested labels
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #40190 +/- ##
=========================================
Coverage 69.85% 69.85%
=========================================
Files 3296 3291 -5
Lines 119166 119054 -112
Branches 21482 21411 -71
=========================================
- Hits 83242 83171 -71
+ Misses 32628 32594 -34
+ Partials 3296 3289 -7
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
|
hey @tassoevan, merge queue removed the PR due to failed Test UI (EE) / MongoDB checks. These seem unrelated to my change (1 line fix in applyQueryOptions.ts). Could you help re-queue or confirm if these are flaky tests? |
043ec2e to
eb7c8d5
Compare
|
Hi @tassoevan , the milestone has been updated to 8.5.0. Could you re-add this to the merge queue? Thank you! |
|
@tassoevan , Dionisio QA is still showing the milestone as 8.4.0. Could you check if the milestone on the PR is correctly set to 8.5.0? The check seems to be picking up the old value.
|
|
@Naetiksoni08 don't worry, its happening because we're in the middle of the release cut |

Proposed changes (including videos or screenshots)
In
applyQueryOptions.ts, the sort loop was incorrectly accessingsortObj.sort.lengthinstead ofsortObj.length.sortObjis an array returned byconvertSort(). Accessing.sorton an array returns the built-inArray.prototype.sortmethod (a function), not the array's length. Since
Array.prototype.sortaccepts 1 argument,.sort.lengthalways returns1regardless of how many sort fields exist.Before:
After:
Impact of the bug:
This affects anywhere applyQueryOptions is called with multi-field sort options, including UserProvider and SettingsProvider.
Steps to test or reproduce
// Proof in browser console:
const arr = ['a', 'b', 'c'];
console.log(arr.sort.length); // always returns 1 which is wrong
console.log(arr.length); // returns 3
Further comments
No tests existed for applyQueryOptions so this was never caught. The fix is a one-word change removing the erroneous .sort access.
Summary by CodeRabbit